<template>
    <div class="table store sever_list">
        <div class="crumbs store_title">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item>咨询详情</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="mainBtn">
            <el-button type="success" @click="addStore()" class="fr" style="margin-left: 20px;">门店情况</el-button>
            <el-button v-if="isRoleName" type="success" @click="openReadHua()" class="fr" style="margin-left: 20px">划拨计划列表</el-button>
            <el-button v-if="isRoleName" type="success" @click="addPeople" class="fr">
                <i class="el-icon-plus"></i>新增划拨计划
            </el-button>
        </div>
        <div class="container">
            <div class="exd_value">
                <div class="fl" style="margin-bottom: 20px;width: 70%;">
                    <el-radio-group @change="showStatus" v-model="radio_status">
                        <el-radio-button label="全部"></el-radio-button>
                        <el-radio-button label="未跟踪"></el-radio-button>
                        <el-radio-button label="跟踪中"></el-radio-button>
                        <el-radio-button label="已加微信"></el-radio-button>
                        <el-radio-button label="失效"></el-radio-button>
                    </el-radio-group>
                    <el-select clearable placeholder="门店" v-model="SearchstoreId" @change="selectStore">
                        <el-option v-for="(item,key) in searchStore" :key="key" :label="item.shop.shopName" :value="item.shop.id"></el-option>
                    </el-select>
                    <el-select style="width: 150px;" v-model="searchRemark" @change="tagDataFn" clearable placeholder="备注类型">
                        <el-option v-for="item in tagData" :label="item" :value="item" :key="item.id"></el-option>
                    </el-select>
                    <br>
                    <el-select style="margin-top: 10px;width: 127px;" @change="timeSelectFn" v-model="searchTime" placeholder="时间类型">
                        <el-option label="下单时间" value="ORDERTIME"></el-option>
                        <el-option label="操作时间" value="ORERATIONTIME"></el-option>
                    </el-select>
                    <el-date-picker :clearable="false" v-model="timeRange" @change="dataSelectFn" type="datetimerange" style="margin-top: 10px;" :picker-options="pickerOptDef" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
                </div>
                <div class="fr" style="vertical-align: top">
                    <el-input clearable style="width: 300px;" v-model="phoneNumber" @change="changePhone" placeholder="输入联系方式" class="checkCoupon_input">
                        <el-button slot="append" icon="el-icon-search" type="success" circle @click="searchPhone(phoneNumber)"></el-button>
                    </el-input>
                </div>
            </div>
            <el-table v-if="activeShow" :data="list" border style="width: 100%" ref="table" @selection-change="handleSelectionChange">
                <el-table-column type="selection"></el-table-column>
                <el-table-column prop="sequenceNum" label="当天序号"></el-table-column>
                <el-table-column prop="content" label="服务产品"></el-table-column>
                <el-table-column prop="shopName" label="门店"></el-table-column>
                <el-table-column v-if="searchTime == 'ORDERTIME'" prop="orderTime" label="下单时间" width="160px"></el-table-column>
                <el-table-column v-else prop="operationTime" label="操作时间" width="160px"></el-table-column>
                <el-table-column prop="contactInfo" label="联系方式" width="260px">
                    <template slot-scope="scope">
                        <div class="sixCol">
                            <el-tag v-html="scope.row.contactType"></el-tag>
                            <el-button size="mini" type="primary" class="copyBtn" @click="copyPhone(scope.$index, scope.row)">{{scope.row.contactInfo}}</el-button>
                            <input type="text" :value="scope.row.contactInfo" :id="'copyPhone'+scope.$index" style="opacity: 0;width: 2px;">
                        </div>
                    </template>
                </el-table-column>
                <el-table-column prop="promoteWishBillStatusEnum" label="状态"></el-table-column>
                <el-table-column label="操作" align="center" width="200px">
                    <template slot-scope="scope">
                        <el-button v-if="isRoleName && (scope.row.promoteWishBillStatusEnum == '加微' || scope.row.promoteWishBillStatusEnum == '失效')" size="small" type="primary" @click="learnFn(scope.$index, scope.row)">修改</el-button>
                        <el-button size="small" type="primary" @click="editFn(scope.$index, scope.row)">详情</el-button>
                    </template>
                </el-table-column>
            </el-table>

            <div class="pagination">
                <el-pagination v-if="paginationShow" :current-page.sync="cur_page" @current-change="handleCurrentChange" @size-change="handleSizeChange" layout="total, sizes, prev, pager, next" :total="pageNum" :page-sizes="[10, 30, 50]" :page-size="pageSize" :current-page="cur_page"></el-pagination>
            </div>
        </div>

        <!-- 新增划拨计划 -->
        <el-dialog :visible.sync="addNewHua" title="划拨计划" width="650px">
            <el-form label-width="120px" ref="HuaboData" :v-model="HuaboData" class="extend_form">
                <el-form-item label="计划名称：">
                    <el-input v-model="HuaboData.logName" style="width: 155px;"></el-input>
                </el-form-item>
                <el-form-item label="状态：">
                    <el-select :disabled="multipleSelectionAll!=''" v-model="HuaboData.promoteWishBillStatusEnum" @change="selectHuaFn" style="width: 155px;">
                        <el-option key="1" label="未跟踪" value="ACTIVATING"></el-option>
                        <el-option key="2" label="跟踪中" value="NORMAL"></el-option>
                        <el-option key="3" label="失效" value="DISABLED"></el-option>
                        <el-option key="4" label="加微" value="WECHAT"></el-option>
                        <el-option key="5" label="全部" value="ALL"></el-option>
                    </el-select>
                    <!--<span style="color: red">*需求单有勾选值时，此状态不可选</span>-->
                    <el-checkbox :disabled="HuaboData.promoteWishBillStatusEnum == 'ACTIVATING' || resetFlags == 4" v-model="HuaboData.resetFlat" style="font-size: 13px;margin-left: 20px;">状态重置</el-checkbox>
                </el-form-item>
                <div style="display: inline-block">
                    <el-form-item label="划拨源：">
                        <el-select v-model="HuaboData.initiatorCounselorId" @focus="selectInitiatorCounselor" @change="selectInitiatorCounselor" style="width: 155px;">
                            <el-option v-for="(item,key) in peopleData" :key="key" :label="item.name" :value="item.id"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="目标人：">
                        <el-select v-model="HuaboData.targetCounselorId" @focus="selectTargetCounselor" @change="selectTargetCounselor" style="width: 155px;">
                            <el-option v-for="(item,key) in targetData" :key="key" :label="item.name" :value="item.id"></el-option>
                        </el-select>
                    </el-form-item>
                </div>
                <div style="display: inline-block">
                    <el-form-item label="划拨源门店：">
                        <el-select :disabled="HuaboData.initiatorCounselorId==''" v-model="HuaboData.initiatorShopId" @focus="selectInitiatorStore" @change="selectInitiatorStore" style="width: 155px;">
                            <el-option v-for="(item,key) in storeData" :key="key" :label="item.shop.shopName" :value="item.shop.id"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="目标门店：" style="visibility: hidden">
                        <el-select :disabled="HuaboData.targetCounselorId==''" v-model="HuaboData.targetShopId" @focus="selectTargetStore" @change="selectTargetStore" style="width: 155px;">
                            <el-option v-for="(item,key) in tarStoreData" :key="key" :label="item.shop.shopName" :value="item.shop.id"></el-option>
                        </el-select>
                    </el-form-item>
                </div>
                <el-form-item label="备注：">
                    <el-input type="textarea" v-model="HuaboData.describe" style="width: 410px;"></el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="addNewHua = false">取 消</el-button>
                <el-button type="primary" @click="saveForm">确 定</el-button>
            </span>
        </el-dialog>

        <!-- 划拨计划列表 -->
        <el-dialog :visible.sync="readNewHua" width="1200px">
            <el-tabs type="border-card" @tab-click="otherChangeTabsClick">
                <el-tab-pane label="组长">
                    <el-table :data="huabo_list" ref="multipleTable" border style="width: 100%">
                        <el-table-column prop="logName" label="名称"></el-table-column>
                        <el-table-column prop="countNum" label="条数"></el-table-column>
                        <el-table-column prop="processStatusEnum" label="状态"></el-table-column>
                        <el-table-column prop="creatorName" label="创建人"></el-table-column>
                        <el-table-column prop="createdTime" label="创建时间"></el-table-column>
                        <el-table-column prop="remark" label="备注" width="200"></el-table-column>
                        <el-table-column label="操作" align="center" width="260">
                            <template slot-scope="scope">
                                <el-button v-if="scope.row.processStatusEnum!='成功'" size="small" type="primary" @click="delFn(scope.$index, scope.row)">删除</el-button>
                                <el-button v-if="scope.row.processStatusEnum!='成功'" size="small" type="primary" @click="doFn(scope.$index, scope.row)">执行</el-button>
                                <el-button size="small" type="primary" @click="readFn(scope.$index, scope.row)">详情</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <div class="pagination">
                        <el-pagination v-if="paginationShow" :current-page.sync="huabo_one_cur_page" @current-change="handleoneCurrentChange" @size-change="handleoneSizeChange" layout="total, prev, pager, next" :total="huabo_one_pageNum" :page-size="huabo_one_pageSize" :current-page="huabo_one_cur_page"></el-pagination>
                    </div>
                </el-tab-pane>
                <el-tab-pane label="组员">
                    <el-table :data="other_huabo_list" ref="multipleTable" border style="width: 100%">
                        <el-table-column prop="logName" label="名称"></el-table-column>
                        <el-table-column prop="countNum" label="条数"></el-table-column>
                        <el-table-column prop="processStatusEnum" label="状态"></el-table-column>
                        <el-table-column prop="creatorName" label="创建人"></el-table-column>
                        <el-table-column prop="createdTime" label="创建时间"></el-table-column>
                        <el-table-column prop="remark" label="备注" width="200"></el-table-column>
                        <el-table-column label="操作" align="center" width="260">
                            <template slot-scope="scope">
                                <!-- <el-button v-if="scope.row.processStatusEnum!='成功'" size="small" type="primary" @click="delFn(scope.$index, scope.row)">删除</el-button> -->
                                <!-- <el-button v-if="scope.row.processStatusEnum!='成功'" size="small" type="primary" @click="doFn(scope.$index, scope.row)">执行</el-button> -->
                                <el-button size="small" type="primary" @click="readFn(scope.$index, scope.row)">详情</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <div class="pagination">
                        <el-pagination v-if="paginationShow" :current-page.sync="other_huabo_one_cur_page" @current-change="other_handleoneCurrentChange" @size-change="other_handleoneSizeChange" layout="total, prev, pager, next" :total="other_huabo_one_pageNum" :page-size="other_huabo_one_pageSize" :current-page="other_huabo_one_cur_page"></el-pagination>
                    </div>
                </el-tab-pane>
            </el-tabs>

            <span slot="footer" class="dialog-footer">
                <el-button @click="readNewHua = false">关 闭</el-button>
                <!-- <el-button type="primary" @click="readNewHua = false">确 定</el-button> -->
            </span>
        </el-dialog>

        <!-- 划拨计划服务产品详情 -->
        <el-dialog :visible.sync="readOneDetail" title="划拨详情" width="700px">
            <el-form label-width="120px" ref="oneHuaboData" :v-model="oneHuaboData" class="extend_form">
                <el-tabs type="border-card" v-model="huaName" @tab-click="tabsClick">
                    <el-tab-pane label="详情" name="detail">
                        <el-form-item style="margin-left: 25px" label="计划名称：">
                            <el-input disabled v-model="oneHuaboData.logName" style="width: 410px;"></el-input>
                        </el-form-item>
                        <el-form-item style="margin-left: 25px" label="创建人：">
                            <el-input disabled v-model="oneHuaboData.creatorName" style="width: 410px;"></el-input>
                        </el-form-item>
                        <div style="width: 250px;margin-left:25px;display: inline-block">
                            <el-form-item label="状态：">
                                <el-select v-model="oneHuaboData.processStatusEnum" @change="selectHuaFn" style="width: 155px;" disabled>
                                    <el-option key="1" label="执行中" value="ACTIVATING"></el-option>
                                    <el-option key="2" label="待执行" value="WAIT"></el-option>
                                    <el-option key="3" label="成功" value="SUCCESS"></el-option>
                                    <el-option key="4" label="错误" value="ERROR"></el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="划拨数量：">
                                <el-input disabled v-model="oneHuaboData.countNum" style="width: 155px;"></el-input>
                            </el-form-item>
                        </div>
                        <div style="width: 250px;display: inline-block">
                            <el-form-item label="完成时间：">
                                <el-input disabled v-model="oneHuaboData.complateTime" style="width: 155px;"></el-input>
                            </el-form-item>
                            <el-form-item label="创建时间：">
                                <el-input disabled v-model="oneHuaboData.createdTime" style="width: 155px;"></el-input>
                            </el-form-item>
                        </div>
                        <el-form-item style="margin-left: 25px" label="执行结果：">
                            <span style="color: red" v-html="oneHuaboData.resultDesc"></span>
                        </el-form-item>
                        <div style="width: 250px;margin-left:25px;display: inline-block">
                            <el-form-item label="划拨源小组：">
                                <el-input disabled v-model="oneHuaboData.counselorDeptNameSource" style="width: 155px;"></el-input>
                            </el-form-item>
                            <el-form-item label="划拨源：">
                                <el-input disabled v-model="oneHuaboData.counselorNameSource" style="width: 155px;"></el-input>
                            </el-form-item>
                            <el-form-item label="划拨源门店：">
                                <el-input disabled v-model="oneHuaboData.shopNameSource" style="width: 155px;"></el-input>
                            </el-form-item>
                        </div>

                        <div style="width: 250px;display: inline-block">
                            <el-form-item label="目标小组：">
                                <el-input disabled v-model="oneHuaboData.counselorDeptNameTarget" style="width: 155px;"></el-input>
                            </el-form-item>
                            <el-form-item label="目标人：">
                                <el-input disabled v-model="oneHuaboData.counseloNameTarget" style="width: 155px;"></el-input>
                            </el-form-item>
                            <el-form-item label="目标门店：">
                                <el-input disabled v-model="oneHuaboData.shopNameTarget" style="width: 155px;"></el-input>
                            </el-form-item>
                        </div>
                        <el-form-item style="margin-left:25px" label="备注：">
                            <el-input disabled type="textarea" v-model="oneHuaboData.remark" style="width: 409px;"></el-input>
                        </el-form-item>
                    </el-tab-pane>
                    <el-tab-pane label="列表" name="list">
                        <el-table v-if="activeShow" :data="service_list" ref="multipleTable" border style="width: 100%">
                            <el-table-column prop="content" label="服务产品" width="150px"></el-table-column>
                            <el-table-column prop="promoteWishBillStatusEnum" label="状态"></el-table-column>
                            <el-table-column prop="promoteWishBillStatusEnumNew" label="更新状态"></el-table-column>
                            <el-table-column prop="orderTime" label="订单时间" width="150px"></el-table-column>
                            <el-table-column prop="contactInfo" label="联系方式"></el-table-column>
                        </el-table>
                        <div class="pagination">
                            <el-pagination v-if="paginationShow" :current-page.sync="huabo_two_cur_page" @current-change="handletwoCurrentChange" @size-change="handletwoSizeChange" layout="total, prev, pager, next" :total="huabo_two_pageNum" :page-size="huabo_two_pageSize" :current-page="huabo_two_cur_page"></el-pagination>
                        </div>
                    </el-tab-pane>
                </el-tabs>
            </el-form>

            <span slot="footer" class="dialog-footer">
                <el-button @click="readOneDetail = false">关 闭</el-button>
                <!-- <el-button type="primary" @click="readOneDetail = false">确 定</el-button> -->
            </span>
        </el-dialog>

        <!-- 咨询详情 -->
        <el-dialog :visible.sync="showDetailDialog" width="650px">
            <el-tabs type="border-card">
                <el-tab-pane label="详情">
                    <ul class="exd_ul" v-model="detailData">
                        <li>
                            <span class="exd_ul_span">服务产品：</span>
                            <span v-html="detailData.content"></span>
                        </li>
                        <li>
                            <span class="exd_ul_span">联系方式：</span>
                            <el-tag v-html="detailData.contactType"></el-tag>
                            <span v-html="detailData.contactInfo"></span>
                            <el-button size="mini" type="primary" class="copyBtn" @click="copysPhone2()">复制</el-button>
                            <input type="text" :value="detailData.contactInfo" id="copyGround2" style="opacity: 0">
                        </li>
                        <li>
                            <span class="exd_ul_span">下单时间：</span>
                            <span v-html="detailData.orderTime"></span>
                        </li>
                        <li>
                            <span class="exd_ul_span">状态：</span>
                            <el-select v-model="select_cate" @change="selectStatusFn" disabled>
                                <el-option key="1" label="未跟踪" value="ACTIVATING"></el-option>
                                <el-option key="2" label="跟踪中" value="NORMAL"></el-option>
                                <el-option key="3" label="失效" value="DISABLED"></el-option>
                                <el-option key="4" label="加微" value="WECHAT"></el-option>
                            </el-select>
                        </li>
                        <li>
                            <span class="exd_ul_span">原表单：</span>
                            <el-table :data="form_list" border style="width: 450px;display: inline-block;vertical-align: top" ref="multipleTable">
                                <el-table-column prop="label" label="表单字段" width="224px"></el-table-column>
                                <el-table-column prop="value" label="表单内容" width="224px"></el-table-column>
                            </el-table>
                        </li>
                    </ul>
                </el-tab-pane>
                <el-tab-pane label="备注列表">
                    <ul class="exd_ul">
                        <li>
                            <!-- <span class="exd_ul_span">备注列表：</span> -->
                            <el-table :data="wishBill_list" border style="width: 580px;display: inline-block;vertical-align: top" ref="multipleTable">
                                <el-table-column prop="name" label="备注人" width="193px"></el-table-column>
                                <el-table-column prop="createdTime" label="备注时间" width="192px" style="font-size: 12px"></el-table-column>
                                <el-table-column prop="content" label="备注内容" width="192px">
                                    <template slot-scope="scope">
                                        <div>{{ scope.row.content | getOPTType(scope.row.content) }}</div>
                                    </template>
                                </el-table-column>
                            </el-table>
                            <el-pagination v-if="paginationShow" style="text-align: right;width: 80%;" @current-change="handlewishBillChange" layout="total, prev, pager, next" :total="wishpageNum" :page-size="wishpageSize" :current-page="wishcur_page"></el-pagination>
                        </li>
                    </ul>
                </el-tab-pane>
            </el-tabs>
            <span slot="footer" class="dialog-footer">
                <el-button v-if="isRoleName" @click="showDetailDialog = false">取 消</el-button>
                <div style="display: inline-block" v-if="isRoleName">
                    <el-button @click="saveEdit" v-if="statusData == 'DISABLED' || statusData == 'WECHAT'">确 定</el-button>
                    <el-button v-else @click="showDetailDialog = false">关 闭</el-button>
                </div>
                <div style="display: inline-block" v-else>
                    <el-button @click="showDetailDialog = false">关 闭</el-button>
                </div>
            </span>
        </el-dialog>

        <!--咨询修改-->
        <el-dialog :visible.sync="learnDialog" width="650px">
            <ul class="exd_ul" v-model="detailData">
                <li>
                    <span class="exd_ul_span">服务产品：</span>
                    <span v-html="detailData.content"></span>
                </li>
                <li>
                    <span class="exd_ul_span">联系方式：</span>
                    <el-tag v-html="detailData.contactType"></el-tag>
                    <span v-html="detailData.contactInfo"></span>
                    <el-button size="mini" type="primary" class="copyBtn" @click="copysPhone()">复制</el-button>
                    <input type="text" :value="detailData.contactInfo" id="copyGround" style="opacity: 0">
                </li>
                <li>
                    <span class="exd_ul_span">下单时间：</span>
                    <span v-html="detailData.orderTime"></span>
                </li>
                <li>
                    <span class="exd_ul_span">状态：</span>
                    <el-select v-if="isRoleName" v-model="select_cate" @change="selectStatusFn" :disabled="statusData == 'ACTIVATING' || statusData == 'NORMAL'">
                        <el-option key="1" label="未跟踪" value="ACTIVATING" disabled></el-option>
                        <el-option key="2" label="跟踪中" value="NORMAL"></el-option>
                        <el-option key="3" label="失效" value="DISABLED" disabled></el-option>
                        <el-option key="4" label="加微" value="WECHAT" disabled></el-option>
                    </el-select>
                    <el-select v-else v-model="select_cate" @change="selectStatusFn" disabled>
                        <el-option key="1" label="未跟踪" value="ACTIVATING"></el-option>
                        <el-option key="2" label="跟踪中" value="NORMAL"></el-option>
                        <el-option key="3" label="失效" value="DISABLED"></el-option>
                        <el-option key="4" label="加微" value="WECHAT"></el-option>
                    </el-select>
                </li>
                <li style="padding-bottom: 0">
                    <span class="exd_ul_span">备注：</span>
                    <textarea v-model="text_data" class="exd-textarea"></textarea>
                    <!--<el-input v-model="text_data" type="textarea" style="width: 400px;vertical-align: top"></el-input>-->
                </li>
                <li style="padding-top: 0">
                    &nbsp;&nbsp;
                    <span class="exd_ul_span"></span>
                    <span style="font-size: 12px;width: 380px;color: red;display: inline-block">
                        <el-tag size="medium" style="margin: 10px 15px 0px -10px;cursor: pointer;" type="warning" v-for="item in tagData" v-on:click.native="chooseTagVal(item)" :key="item.id">{{item}}</el-tag>
                    </span>
                </li>
            </ul>
            <span slot="footer" class="dialog-footer">
                <el-button v-if="isRoleName" @click="learnDialog = false">取 消</el-button>
                <div style="display: inline-block" v-if="isRoleName">
                    <el-button @click="saveEdit" v-if="statusData == 'DISABLED' || statusData == 'WECHAT'">确 定</el-button>
                    <el-button v-else @click="learnDialog = false">关 闭</el-button>
                </div>
                <div style="display: inline-block" v-else>
                    <el-button @click="learnDialog = false">关 闭</el-button>
                </div>
            </span>
        </el-dialog>

        <!-- 门店情况 -->
        <el-dialog :visible.sync="addStoreDialog" width="900px">
            <el-select style="margin-top: 10px;width: 120px;" @change="timeStoreFn" v-model="StoreTime" placeholder="时间类型">
                <el-option label="下单时间" value="ORDERTIME"></el-option>
                <el-option label="操作时间" value="ORERATIONTIME"></el-option>
            </el-select>
            <el-date-picker :clearable="false" v-model="TimeValue" @change="dataStoreFn" type="datetimerange" :picker-options="pickerOptDef" style="margin-bottom: 20px" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
            <el-table v-if="activeShow" :data="detailStore" border style="width: 100%;" ref="multipleTable" show-summary :summary-method="getSummaries" @selection-change="handleSelectionChange">
                <el-table-column prop="shopName" label="店名" width="200px" :filters="listshopName" :filter-method="filterHandler"></el-table-column>
                <el-table-column prop="dereceiveNum" label="客户总数"></el-table-column>
                <el-table-column prop="receiveNum" label="未跟踪"></el-table-column>
                <el-table-column prop="addWechatNum" label="加微数"></el-table-column>
                <el-table-column prop="addWechatSurpriseNum" label="额外加微数"></el-table-column>
                <el-table-column prop="invalidNum" label="无效数"></el-table-column>
                <el-table-column prop="tailAfterNum" label="跟踪数"></el-table-column>
                <el-table-column prop="rate" label="通过率"></el-table-column>
                <el-table-column prop="rateAll" label="总通过率"></el-table-column>
            </el-table>
        </el-dialog>
    </div>
</template>

<script>
import { storeAsGet, storeAsPost, storeAsPut } from "../api/api"
import { formatDate } from "../tool/tool"
import { base64, tool_confirm } from "../tool/tool"
export default {
    data() {
        return {
            tagData: [
                "待通过",
                "已通过",
                "未接",
                "空号",
                "停机",
                "微信不存在",
                "不需要",
                "挂电话",
                "老客户",
                "未参加",
                "拒加微信",
                "骂人"
            ],
            learnDialog: false,
            SearchstoreId: "",
            //备注
            searchRemark: "",
            //时间类型
            searchTime: "ORDERTIME",
            //时间
            timeRange: "",
            //手机号查询
            phoneNumber: "",
            searchStore: [],
            //列表数据
            list: [],
            //分页
            pageNum: null,
            paginationShow: true,
            cur_page: 0,
            pageSize: 10,
            wishpageNum: null,
            wishcur_page: 0,
            wishpageSize: 10,
            showDetailDialog: false,
            radio_status: "未跟踪",
            promoteStatusEnum: "ACTIVATING",
            detailData: {},
            form_list: [],
            //备注列表
            wishBill_list: [],
            wishBillId: "",
            // 状态
            select_cate: "",
            //  选择划拨数据
            //点击划拨显示模块
            addHuaDialog: false,
            huabo_list: [],
            service_list: [],
            huabo_one_pageNum: null,
            huabo_one_pageSize: 10,
            huabo_one_cur_page: 0,
            // 组员的划拨显示模块
            other_huabo_list: [],
            other_huabo_one_pageNum: null,
            other_huabo_one_pageSize: 10,
            other_huabo_one_cur_page: 0,
            other_counselorId: "",
            //点击新增显示模块
            addNewHua: false,
            HuaboData: {
                logName: "",
                targetCounselorId: "",
                initiatorCounselorId: "",
                initiatorShopId: "",
                targetShopId: "",
                describe: "",
                promoteWishBillStatusEnum: "",
                wishBillList: [],
                //状态重置
                resetFlat: false
            },
            // 人员列表
            peopleData: [],
            targetData: [],
            // 门店
            storeData: [],
            tarStoreData: [],
            readOneDetail: false,
            readNewHua: false,
            oneHuaboData: {},
            huaName: "detail",
            huabo_two_pageNum: null,
            huabo_two_pageSize: 10,
            huabo_two_cur_page: 0,
            // 多选
            multipleSelection: [],
            idKey: "barcode", // 标识列表数据中每一行的唯一键的名称
            tableData: [], // 表格数据
            multipleSelectionAll: [], //所有选中的数据包含跨页数据
            //  组员列表
            people_list: [],
            currentRow: "",
            personId: "",
            personHuaForm: {},
            checkOther: false,
            isRoleName: false,
            statusData: "",
            trueForm: {},
            text_data: "",
            activeShow: true,
            resetFlags: 3,
            pickerOptions: {
                shortcuts: [
                    {
                        text: "今天",
                        onClick(picker) {
                            const end = new Date()
                            end.setTime(end.getTime())
                            end.setHours(23)
                            end.setMinutes(59)
                            end.setSeconds(59)
                            console.log(end, 115)
                            end.setTime(end.getTime())
                            const start = new Date()
                            start.setHours(0)
                            start.setMinutes(0)
                            start.setSeconds(0)
                            start.setTime(start.getTime())
                            picker.$emit("pick", [start, end])
                        }
                    },
                    {
                        text: "昨天",
                        onClick(picker) {
                            const end = new Date()
                            end.setTime(end.getTime() - 3600 * 1000 * 24 * 1)
                            end.setHours(23)
                            end.setMinutes(59)
                            end.setSeconds(59)
                            console.log(end, 115)
                            end.setTime(end.getTime())
                            const start = new Date()
                            start.setHours(0)
                            start.setMinutes(0)
                            start.setSeconds(0)
                            start.setTime(
                                start.getTime() - 3600 * 1000 * 24 * 1
                            )
                            picker.$emit("pick", [start, end])
                        }
                    },
                    {
                        text: "最近7天",
                        onClick(picker) {
                            const end = new Date()
                            end.setHours(23)
                            end.setMinutes(59)
                            end.setSeconds(59)
                            end.setTime(end.getTime())
                            const start = new Date()
                            start.setHours(0)
                            start.setMinutes(0)
                            start.setSeconds(0)
                            start.setTime(
                                start.getTime() - 3600 * 1000 * 24 * 6
                            )
                            picker.$emit("pick", [start, end])
                        }
                    },
                    {
                        text: "最近30天",
                        onClick(picker) {
                            const end = new Date()
                            end.setHours(23)
                            end.setMinutes(59)
                            end.setSeconds(59)
                            end.setTime(end.getTime())
                            const start = new Date()
                            start.setHours(0)
                            start.setMinutes(0)
                            start.setSeconds(0)
                            start.setTime(
                                start.getTime() - 3600 * 1000 * 24 * 29
                            )
                            picker.$emit("pick", [start, end])
                        }
                    },
                    {
                        text: "最近90天",
                        onClick(picker) {
                            const end = new Date()
                            end.setHours(23)
                            end.setMinutes(59)
                            end.setSeconds(59)
                            end.setTime(end.getTime())
                            const start = new Date()
                            start.setHours(0)
                            start.setMinutes(0)
                            start.setSeconds(0)
                            start.setTime(
                                start.getTime() - 3600 * 1000 * 24 * 89
                            )
                            picker.$emit("pick", [start, end])
                        }
                    }
                ]
            },
            //门店情况
            addStoreDialog: false,
            TimeValue: "",
            detailStore: [],
            StoreTime: 'ORDERTIME',
            listshopName: [],
        }
    },
    created() {
        this.dataSelectFn()
        this.getListStore()
        this.getCustomerList(this.cur_page)
        // 门店情况
        // this.dataStoreFn()
    },
    computed: {},
    watch: {
        $route() {
            if (this.$route.path == "/extendDetail") {
                this.getCustomerList(0)
                console.log(this.$route.query.id, "this.$route.query.id461")
                console.log(this.$route.path, "551")
                if (this.$route.query.id != undefined) {
                    this.getListStore()
                }
            }
        }
    },
    methods: {
        chooseTagVal(val) {
            this.text_data = val
        },
        copyPhone(index, row) {
            let url = document.getElementById("copyPhone" + index)
            console.log(url)
            url.select()
            document.execCommand("Copy")
            this.$message.success("复制成功")
        },
        copysPhone() {
            let url = document.getElementById("copyGround")
            url.select()
            document.execCommand("Copy")
            this.$message.success("复制成功")
        },
        copysPhone2() {
            let url = document.getElementById("copyGround2")
            url.select()
            document.execCommand("Copy")
            this.$message.success("复制成功")
        },
        // 获取门店列表
        getListStore() {
            storeAsGet(
                "counselor/detail/shop/list?counselorId=" + this.$route.query.id
            )
                .then(res => {
                    this.searchStore = res.data.content.detail
                })
                .catch(errors => {
                    this.$message.error(errors.response.data.detail)
                })
        },
        //获取组员列表
        getPopeleList() {
            if (this.$route.query.groupid) {
                storeAsGet(
                    "/counselor/list/dept?counselorDeptId=" +
                        this.$route.query.groupid
                ).then(res => {
                    console.log(res, "167")
                    this.people_list = res.data.content.list
                })
            } else {
                storeAsGet("/counselor/list/dept?counselorDeptId=").then(
                    res => {
                        console.log(res, "167")
                        this.people_list = res.data.content.list
                    }
                )
            }
        },
        //划拨
        addPeople() {
            this.HuaboData = {}
            this.HuaboData = {
                logName: "",
                targetCounselorId: "",
                initiatorCounselorId: "",
                initiatorShopId: "",
                targetShopId: "",
                describe: "",
                promoteWishBillStatusEnum: "",
                wishBillList: [],
                resetFlat: false
            }
            if (this.multipleSelectionAll != "") {
                if (this.multipleSelectionAll[0].promoteWishBillStatusEnum == "未跟踪" || this.radio_status == '全部' || this.radio_status == '跟踪中') {
                    this.resetFlags = 4
                } else {
                    this.resetFlags = 3
                }
                // console.log( this.multipleSelectionAll[0],"551")
            } else {
                this.resetFlags = 3
            }
            this.addNewHua = true
        },
        selectInitiatorCounselor() {
            this.HuaboData.initiatorShopId = ""
            storeAsGet("counselor/list/deptId?counselorDeptId=")
                .then(res => {
                    this.peopleData = res.data.content.list
                })
                .catch(errors => {
                    this.$message.error(errors.response.data.detail)
                })
        },
        selectInitiatorStore() {
            storeAsGet(
                "counselor/detail/shop/list?counselorId=" +
                    this.HuaboData.initiatorCounselorId
            )
                .then(res => {
                    this.storeData = res.data.content.detail
                })
                .catch(errors => {
                    this.$message.error(errors.response.data.detail)
                })
        },
        selectTargetCounselor() {
            this.HuaboData.targetShopId = ""
            storeAsGet("counselor/list/deptId?counselorDeptId=")
                .then(res => {
                    this.targetData = res.data.content.list
                })
                .catch(errors => {
                    this.$message.error(errors.response.data.detail)
                })
        },
        selectTargetStore() {
            storeAsGet(
                "counselor/detail/shop/list?counselorId=" +
                    this.HuaboData.targetCounselorId
            )
                .then(res => {
                    this.tarStoreData = res.data.content.detail
                })
                .catch(errors => {
                    this.$message.error(errors.response.data.detail)
                })
        },
        // 新增
        saveForm() {
            let newAllID = []
            if (this.multipleSelectionAll != "") {
                this.multipleSelectionAll.map(item => {
                    newAllID.push(item.id)
                })
                this.HuaboData.wishBillList = newAllID
                // console.log(this.HuaboData,"522");
            }
            // 去除目标门店，把源门店赋给目标门店
            this.HuaboData.targetShopId = this.HuaboData.initiatorShopId

            storeAsPost(this.HuaboData, "/promote/transFrom/log/detail")
                .then(res => {
                    this.addNewHua = false
                    this.$message.success(`新建成功`)
                    this.multipleSelectionAll = []
                    this.multipleSelection = []
                    this.cur_page = 1
                    this.getCustomerList(1, 2)
                })
                .catch(errors => {
                    this.$message.error(errors.response.data.detail)
                })
        },

        //划拨计划列表
        readHua(curPage, counselorId) {
            this.readNewHua = true
            if (curPage == 0) {
                this.activeShow = false
                this.paginationShow = false
                this.$nextTick(function() {
                    this.activeShow = true
                    this.huabo_one_cur_page = 1
                    this.paginationShow = true
                })
            }
            let filters = {
                formatDate(time) {
                    let date = new Date(time)
                    return formatDate(date, "yyyy-MM-dd hh:mm:ss")
                }
            }
            let url = counselorId
                ? "promote/transFrom/log/page/self?page=" +
                  curPage +
                  "&size=10&counselorId=" +
                  counselorId
                : "promote/transFrom/log/page/self?page=" + curPage + "&size=10"
            storeAsGet(url)
                .then(res => {
                    this.readNewHua = true
                    // console.log(res,"480")
                    if (counselorId) {
                        this.other_huabo_one_pageNum =
                            res.data.content.page.totalElements
                        this.other_huabo_list = res.data.content.page.content
                        Array.prototype.slice
                            .call(this.other_huabo_list)
                            .forEach((value, index) => {
                                value.createdTime = filters.formatDate(
                                    value.createdTime
                                )
                                switch (value.processStatusEnum) {
                                    case "ACTIVATING":
                                        value.processStatusEnum = "执行中"
                                        break
                                    case "WAIT":
                                        value.processStatusEnum = "待执行"
                                        break
                                    case "SUCCESS":
                                        value.processStatusEnum = "成功"
                                        break
                                    case "ERROR":
                                        value.processStatusEnum = "错误"
                                        break
                                }
                            })
                    } else {
                        this.huabo_one_pageNum = res.data.content.page.totalElements
                        this.huabo_list = res.data.content.page.content
                        Array.prototype.slice
                            .call(this.huabo_list)
                            .forEach((value, index) => {
                                value.createdTime = filters.formatDate(
                                    value.createdTime
                                )
                                switch (value.processStatusEnum) {
                                    case "ACTIVATING":
                                        value.processStatusEnum = "执行中"
                                        break
                                    case "WAIT":
                                        value.processStatusEnum = "待执行"
                                        break
                                    case "SUCCESS":
                                        value.processStatusEnum = "成功"
                                        break
                                    case "ERROR":
                                        value.processStatusEnum = "错误"
                                        break
                                }
                            })
                    }
                })
                .catch(errors => {
                    this.$message.error(errors.response.data.detail)
                })
        },
        // 分页导航(计划列表)
        handleoneCurrentChange(val) {
            this.huabo_one_cur_page = val
            this.readHua(val - 1)
        },
        handleoneSizeChange(val) {
            // console.log(val,111111)
        },

        // 分页导航(计划列表)
        other_handleoneCurrentChange(val) {
            this.huabo_one_cur_page = val
            this.readHua(val - 1)
        },
        other_handleoneSizeChange(val) {
            // console.log(val,111111)
        },

        readFn(index, row) {
            this.activeShow = false
            this.$nextTick(function() {
                this.activeShow = true
            })
            let filters = {
                formatDate(time) {
                    let date = new Date(time)
                    return formatDate(date, "yyyy-MM-dd hh:mm:ss")
                }
            }
            this.huaName = "detail"
            this.logId = row.id
            console.log(index, row.id, "765")
            storeAsGet("promote/transFrom/log?id=" + row.id)
                .then(res => {
                    this.readOneDetail = true
                    console.log(res, "480")
                    this.oneHuaboData = res.data.content.entity
                    if (this.oneHuaboData.complateTime) {
                        this.oneHuaboData.complateTime = filters.formatDate(
                            this.oneHuaboData.complateTime
                        )
                    }
                    this.oneHuaboData.createdTime = filters.formatDate(
                        this.oneHuaboData.createdTime
                    )
                })
                .catch(errors => {
                    this.$message.error(errors.response.data.detail)
                })
            this.readDetailList(0)
            console.log("readFn")
        },
        //划拨计划单条服务列表
        readDetailList(curPage) {
            if (curPage == 0) {
                this.activeShow = false
                this.paginationShow = false
                this.$nextTick(function() {
                    this.activeShow = true
                    this.huabo_two_cur_page = 1
                    this.paginationShow = true
                })
            }
            let filters = {
                formatDate(time) {
                    let date = new Date(time)
                    return formatDate(date, "yyyy-MM-dd hh:mm:ss")
                }
            }
            storeAsGet(
                "promote/transFrom/page?page=" +
                    curPage +
                    "&size=10&promoteWishBillTransFromLogId=" +
                    this.logId
            )
                .then(res => {
                    this.readOneDetail = true
                    console.log(res, "480")
                    this.service_list = res.data.content.page.content
                    this.huabo_two_pageNum = res.data.content.page.totalElements
                    Array.prototype.slice
                        .call(this.service_list)
                        .forEach((value, index) => {
                            value.orderTime = filters.formatDate(
                                value.orderTime
                            )
                            switch (value.promoteWishBillStatusEnum) {
                                case "ACTIVATING":
                                    value.promoteWishBillStatusEnum = "未跟踪"
                                    break
                                case "NORMAL":
                                    value.promoteWishBillStatusEnum = "跟踪中"
                                    break
                                case "DISABLED":
                                    value.promoteWishBillStatusEnum = "失效"
                                    break
                                case "WECHAT":
                                    value.promoteWishBillStatusEnum = "加微"
                                    break
                            }
                            switch (value.promoteWishBillStatusEnumNew) {
                                case "ACTIVATING":
                                    value.promoteWishBillStatusEnumNew =
                                        "未跟踪"
                                    break
                                case "NORMAL":
                                    value.promoteWishBillStatusEnumNew =
                                        "跟踪中"
                                    break
                                case "DISABLED":
                                    value.promoteWishBillStatusEnumNew = "无效"
                                    break
                                case "WECHAT":
                                    value.promoteWishBillStatusEnumNew = "加微"
                                    break
                            }
                        })
                })
                .catch(errors => {
                    this.$message.error(errors.response.data.detail)
                })
        },
        //分页导航(服务产品列表)
        handletwoCurrentChange(val) {
            this.huabo_two_cur_page = val
            this.readDetailList(val - 1)
        },
        handletwoSizeChange(val) {
            // console.log(val,111111)
        },
        tabsClick(tab, event) {
            this.activeShow = false
            this.$nextTick(function() {
                this.activeShow = true
            })
            // console.log(tab, event,"handleClick");
        },
        delFn(index, row) {
            tool_confirm(this, "是否要删除此条划拨计划？")
                .then(res => {
                    storeAsPut(
                        "/promote/transFrom/log/detail/delete?promoteWishBillTransFromLogId=" +
                            row.id
                    )
                        .then(res => {
                            this.$message.success(`删除成功`)
                            this.readHua(0)
                        })
                        .catch(errors => {
                            this.$message.error(errors.response.data.detail)
                        })
                })
                .catch(() => {
                    console.log("取消")
                })
        },
        doFn(index, row) {
            tool_confirm(this, "是否要执行此条划拨计划？")
                .then(res => {
                    let formObj = {
                        promoteWishBillTransFromLogId: row.id
                    }
                    console.log(formObj, "formObj")
                    storeAsPost(
                        formObj,
                        "promote/transFrom/log/excute?promoteWishBillTransFromLogId=" +
                            row.id
                    )
                        .then(res => {
                            this.$message.success(`执行成功`)
                            this.readHua(this.huabo_one_cur_page - 1)
                        })
                        .catch(errors => {
                            this.$message.error(errors.response.data.detail)
                        })
                })
                .catch(() => {
                    console.log("取消")
                })
        },
        // 选择划拨状态
        selectHuaFn() {},
        //划拨结束
        //获取组员服务产品列表
        getCustomerList(curPage, val) {
            this.activeShow = false
            this.paginationShow = false
            this.$nextTick(function() {
                this.activeShow = true
                this.paginationShow = true
            })
            // console.log(localStorage.getItem('roleName'))
            let data = {}
            data["page"] = this.cur_page + 1
            // console.log(this.cur_page,"this.page.currentPage")
            data["pnum"] = this.pageNum
            if (localStorage.getItem("roleName") == "咨询组长") {
                this.isRoleName = true
            }
            let filters = {
                formatDate(time) {
                    let date = new Date(time)
                    return formatDate(date, "yyyy-MM-dd hh:mm:ss")
                }
            }
            if (this.$route.query.id == undefined) {
                this.$route.query.id = ""
            }
            if (val == "phone") {
                let phonepage = curPage - 1
                storeAsGet(
                    "/promote/wishBill/page/contactInfo?contactInfo=" +
                        this.phoneNumber +
                        "&page=" +
                        phonepage +
                        "&size=" +
                        this.pageSize
                ).then(res => {
                    // console.log(res,"98")
                    this.pageNum = res.data.content.page.totalElements
                    this.list = res.data.content.page.content
                        ? res.data.content.page.content
                        : []
                    // this.cur_page = res.data.content.page.number;
                    setTimeout(() => {
                        this.setSelectRow()
                    }, 50)
                    Array.prototype.slice
                        .call(this.list)
                        .forEach((value, index) => {
                            value.orderTime = filters.formatDate(
                                value.orderTime
                            )
                            value.operationTime = filters.formatDate(
                                value.operationTime
                            )
                            switch (value.contactType) {
                                case "PHONE":
                                    value.contactType = "手机"
                                    break
                                case "PHONE_WECHAT":
                                    value.contactType = "手机/微信"
                                    break
                                case "WEHCAT":
                                    value.contactType = "微信"
                                    break
                                case "EMAIL":
                                    value.contactType = "邮箱"
                                    break
                                case "QQ":
                                    value.contactType = "QQ"
                                    break
                            }
                            switch (value.promoteWishBillStatusEnum) {
                                case "ACTIVATING":
                                    value.promoteWishBillStatusEnum = "未跟踪"
                                    break
                                case "NORMAL":
                                    value.promoteWishBillStatusEnum = "跟踪中"
                                    break
                                case "WECHAT":
                                    value.promoteWishBillStatusEnum = "加微"
                                    break
                                case "DISABLED":
                                    value.promoteWishBillStatusEnum = "失效"
                                    break
                            }
                        })
                })
            } else if (val == 2) {
                let pages = curPage - 1
                storeAsGet(
                    "/promote/wishBill/page/wishBillStatus?page=" +
                        pages +
                        "&size=" +
                        this.pageSize +
                        "&promoteWishBillStatusEnum=" +
                        this.promoteStatusEnum +
                        "&counselorId=" +
                        this.$route.query.id +
                        "&shopId=" +
                        this.SearchstoreId +
                        "&timeType=" +
                        this.searchTime +
                        "&startTime=" +
                        this.startTime +
                        "&endTime=" +
                        this.endTime +
                        "&comment=" +
                        this.searchRemark
                ).then(res => {
                    console.log(res, "97")
                    this.pageNum = res.data.content.page.totalElements
                    this.list = res.data.content.page.content
                        ? res.data.content.page.content
                        : []
                    this.cur_page = res.data.content.page.number + 1
                    setTimeout(() => {
                        this.setSelectRow()
                    }, 50)
                    Array.prototype.slice
                        .call(this.list)
                        .forEach((value, index) => {
                            value.orderTime = filters.formatDate(
                                value.orderTime
                            )
                            value.operationTime = filters.formatDate(
                                value.operationTime
                            )
                            switch (value.contactType) {
                                case "PHONE":
                                    value.contactType = "手机"
                                    break
                                case "PHONE_WECHAT":
                                    value.contactType = "手机/微信"
                                    break
                                case "WEHCAT":
                                    value.contactType = "微信"
                                    break
                                case "EMAIL":
                                    value.contactType = "邮箱"
                                    break
                                case "QQ":
                                    value.contactType = "QQ"
                                    break
                            }
                            switch (value.promoteWishBillStatusEnum) {
                                case "ACTIVATING":
                                    value.promoteWishBillStatusEnum = "未跟踪"
                                    break
                                case "NORMAL":
                                    value.promoteWishBillStatusEnum = "跟踪中"
                                    break
                                case "WECHAT":
                                    value.promoteWishBillStatusEnum = "加微"
                                    break
                                case "DISABLED":
                                    value.promoteWishBillStatusEnum = "失效"
                                    break
                            }
                        })
                })
            } else {
                storeAsGet(
                    "/promote/wishBill/page/wishBillStatus?page=" +
                        curPage +
                        "&size=" +
                        this.pageSize +
                        "&promoteWishBillStatusEnum=" +
                        this.promoteStatusEnum +
                        "&counselorId=" +
                        this.$route.query.id +
                        "&shopId=" +
                        this.SearchstoreId +
                        "&timeType=" +
                        this.searchTime +
                        "&startTime=" +
                        this.startTime +
                        "&endTime=" +
                        this.endTime +
                        "&comment=" +
                        this.searchRemark
                ).then(res => {
                    console.log(res, "98")
                    this.pageNum = res.data.content.page.totalElements
                    this.list = res.data.content.page.content
                        ? res.data.content.page.content
                        : []
                    this.cur_page = res.data.content.page.number
                    setTimeout(() => {
                        this.setSelectRow()
                    }, 50)
                    Array.prototype.slice
                        .call(this.list)
                        .forEach((value, index) => {
                            value.orderTime = filters.formatDate(
                                value.orderTime
                            )
                            value.operationTime = filters.formatDate(
                                value.operationTime
                            )
                            switch (value.contactType) {
                                case "PHONE":
                                    value.contactType = "手机"
                                    break
                                case "PHONE_WECHAT":
                                    value.contactType = "手机/微信"
                                    break
                                case "WEHCAT":
                                    value.contactType = "微信"
                                    break
                                case "EMAIL":
                                    value.contactType = "邮箱"
                                    break
                                case "QQ":
                                    value.contactType = "QQ"
                                    break
                            }
                            switch (value.promoteWishBillStatusEnum) {
                                case "ACTIVATING":
                                    value.promoteWishBillStatusEnum = "未跟踪"
                                    break
                                case "NORMAL":
                                    value.promoteWishBillStatusEnum = "跟踪中"
                                    break
                                case "WECHAT":
                                    value.promoteWishBillStatusEnum = "加微"
                                    break
                                case "DISABLED":
                                    value.promoteWishBillStatusEnum = "失效"
                                    break
                            }
                        })
                })
            }
        },
        //手机号查询
        changePhone(val) {
            console.log(val, "1035")
            if (val == "") {
                this.paginationShow = false
                this.$nextTick(function() {
                    // this.cur_page = 1;
                    this.paginationShow = true
                })
                this.getCustomerList(0)
            }
        },
        searchPhone(val) {
            this.paginationShow = false
            this.$nextTick(function() {
                this.cur_page = 1
                this.paginationShow = true
            })
            this.phoneNumber = val
            console.log(this.phoneNumber, 1)
            this.getCustomerList(1, "phone")
        },
        // 切换状态
        showStatus(e) {
            console.log(e, "启用")
            this.phoneNumber = ""
            this.multipleSelection = []
            this.multipleSelectionAll = []
            let filters = {
                formatDate(time) {
                    let date = new Date(time)
                    return formatDate(date, "yyyy-MM-dd hh:mm:ss")
                }
            }
            if (e == "未跟踪") {
                this.promoteStatusEnum = "ACTIVATING"
            } else if (e == "跟踪中") {
                this.promoteStatusEnum = "NORMAL"
            } else if (e == "失效") {
                this.promoteStatusEnum = "DISABLED"
            } else if (e == "已加微信") {
                this.promoteStatusEnum = "WECHAT"
            } else if (e == "全部") {
                this.promoteStatusEnum = ""
            }
            this.paginationShow = false
            // this.cur_page = this.cur_page-1;
            this.handleCurrentChange(0)
            this.$nextTick(function() {
                this.paginationShow = true
            })
        },
        selectStore() {
            this.phoneNumber = ""
            this.getCustomerList(0)
        },
        // 时间类型
        timeSelectFn(val) {
            this.phoneNumber = ""
            this.searchTime = val
            this.getCustomerList(0)
        },
        //备注
        tagDataFn(val) {
            this.phoneNumber = ""
            this.searchRemark = val
            this.getCustomerList(0)
        },
        //时间区间
        dataSelectFn(data) {
            //日期搜索预约列表
            this.phoneNumber = ""
            var time = new Date().setHours(0, 0, 0, 0)
            var ThreeDayAgo = time - 86400000 * 3 //一天86400秒
            let a = new Date(time)
            let b = new Date(ThreeDayAgo)
            // var time2= new Date().getTime();
            let startTime =
                formatDate(b, "yyyy-MM-dd hh:mm:ss").substring(0, 10) +
                " 00:00:00"
            let endTime =
                formatDate(new Date(), "yyyy-MM-dd hh:mm:ss").substring(0, 10) +
                " 23:59:59"
            console.log(data, startTime, endTime)

            if (!data) {
                let data = []
                data[0] = startTime
                data[1] = endTime
                this.startTime = data[0]
                this.endTime = data[1]
                this.timeRange = data
            } else {
                this.startTime = formatDate(data[0], "yyyy-MM-dd hh:mm:ss")
                this.endTime = formatDate(data[1], "yyyy-MM-dd hh:mm:ss")
            }
            this.getCustomerList(0)

            console.log(this.timeRange, "timeRange")
        },
        // 备注列表
        getwishBillList(curpage, val) {
            let filters = {
                formatDate(time) {
                    let date = new Date(time)
                    return formatDate(date, "yyyy-MM-dd hh:mm:ss")
                }
            }
            if (val == 2) {
                storeAsGet(
                    "/promote/wishBill/page/wishBillComent?page=" +
                        curpage +
                        "&size=10&promoteWishBillId=" +
                        this.wishBillId
                ).then(res => {
                    this.wishpageNum = res.data.content.page.totalElements
                    this.wishBill_list = res.data.content.page.content
                    console.log(res.data.content.page.content, "wishBill_list")
                    Array.prototype.slice
                        .call(this.wishBill_list)
                        .forEach((value, index) => {
                            value.createdTime = filters.formatDate(
                                value.createdTime
                            )
                        })
                })
            } else {
                storeAsGet(
                    "/promote/wishBill/page/wishBillComent?page=" +
                        this.wishcur_page +
                        "&size=10&promoteWishBillId=" +
                        this.wishBillId
                ).then(res => {
                    this.wishpageNum = res.data.content.page.totalElements
                    this.wishBill_list = res.data.content.page.content
                    console.log(res.data.content.page.content, "wishBill_list")
                    Array.prototype.slice
                        .call(this.wishBill_list)
                        .forEach((value, index) => {
                            value.createdTime = filters.formatDate(
                                value.createdTime
                            )
                        })
                })
            }
        },
        handlewishBillChange(val) {
            console.log(val, "handleCurrentChange")
            this.wishcur_page = val
            this.getwishBillList(val - 1, 2)
        },
        //修改状态
        selectStatusFn(arr) {
            //状态搜索预约列表
            console.log(arr, 99669966)
            console.log(this.select_cate, "sss")
        },
        learnFn(e, val) {
            this.learnDialog = true
            this.text_data = ""
            this.wishBillId = val.id
            let filters = {
                formatDate(time) {
                    let date = new Date(time)
                    return formatDate(date, "yyyy-MM-dd hh:mm:ss")
                }
            }
            storeAsGet(
                "/promote/wishBill/detail?promoteWishBillId=" + val.id
            ).then(res => {
                this.getwishBillList(0, 2)
                this.detailData = res.data.content.detail
                switch (this.detailData.contactType) {
                    case "PHONE_WECHAT":
                        this.detailData.contactType = "手机/微信"
                        break
                    case "WEHCAT":
                        this.detailData.contactType = "微信"
                        break
                    case "PHONE":
                        this.detailData.contactType = "手机"
                        break
                    case "EMAIL":
                        this.detailData.contactType = "邮箱"
                        break
                    case "QQ":
                        this.detailData.contactType = "QQ"
                        break
                }
                // if(this.detailData.contactType == ''){
                //
                // }
                this.detailData.orderTime = filters.formatDate(
                    this.detailData.orderTime
                )
                console.log(res.data.content.detail, "177")
                this.form_list = JSON.parse(this.detailData.wishBillFrom)
                console.log(this.form_list)
                this.select_cate = this.detailData.promoteWishBillStatusEnum
                this.statusData = this.detailData.promoteWishBillStatusEnum
                // var ss = this.detailData.wishBillFrom.split('}');
                // this.form_list = this.detailData.wishBillFrom;
            })
        },
        //修改
        editFn(e, val) {
            console.log(val, "需求单")
            this.showDetailDialog = true
            this.paginationShow = false
            this.$nextTick(function() {
                this.wishcur_page = 1
                this.paginationShow = true
            })
            this.text_data = ""
            this.wishBillId = val.id
            let filters = {
                formatDate(time) {
                    let date = new Date(time)
                    return formatDate(date, "yyyy-MM-dd hh:mm:ss")
                }
            }
            storeAsGet(
                "/promote/wishBill/detail?promoteWishBillId=" + val.id
            ).then(res => {
                this.getwishBillList(0, 2)
                this.detailData = res.data.content.detail
                switch (this.detailData.contactType) {
                    case "PHONE_WECHAT":
                        this.detailData.contactType = "手机/微信"
                        break
                    case "WEHCAT":
                        this.detailData.contactType = "微信"
                        break
                    case "PHONE":
                        this.detailData.contactType = "手机"
                        break
                    case "EMAIL":
                        this.detailData.contactType = "邮箱"
                        break
                    case "QQ":
                        this.detailData.contactType = "QQ"
                        break
                }
                // if(this.detailData.contactType == ''){
                //
                // }
                this.detailData.orderTime = filters.formatDate(
                    this.detailData.orderTime
                )
                console.log(res.data.content.detail, "177")
                this.form_list = JSON.parse(this.detailData.wishBillFrom)
                console.log(this.form_list)
                this.select_cate = this.detailData.promoteWishBillStatusEnum
                this.statusData = this.detailData.promoteWishBillStatusEnum
                // var ss = this.detailData.wishBillFrom.split('}');
                // this.form_list = this.detailData.wishBillFrom;
            })
        },
        // 保存编辑
        saveEdit() {
            console.log(this.select_cate, this.text_data, this.wishBillId)
            this.trueForm = {
                promoteWishBillStatusEnum: this.select_cate,
                promoteWishBillComment: this.text_data,
                promoteWishBillId: this.wishBillId
            }
            storeAsPut(
                "/promote/wishBill/detail?promoteWishBillStatusEnum=" +
                    this.select_cate +
                    "&promoteWishBillComment=" +
                    this.text_data +
                    "&promoteWishBillId=" +
                    this.wishBillId,
                this.trueForm
            )
                .then(res => {
                    this.showDetailDialog = false
                    this.$message.success(`修改成功`)
                    this.getCustomerList(this.cur_page - 1)
                })
                .catch(errors => {
                    this.$message.error(errors.response.data.detail)
                })
        },
        setCurrentRow(val) {
            console.log(val, "1")
            this.personId = val.id
        },
        // 分页导航
        handleCurrentChange(val) {
            this.cur_page = val
            this.changePageCoreRecordData()
            if (this.phoneNumber == "") {
                this.getCustomerList(val, 2)
            } else {
                this.getCustomerList(val, "phone")
            }
            console.log(this.cur_page)
        },
        handleSelectionChange(val) {
            console.log(val, "val")
            val.map(item => {
                item.idKey = this.idKey
            })
            this.multipleSelection = val
            //实时记录选中的数据
            setTimeout(() => {
                this.changePageCoreRecordData()
            }, 50)
        },
        //多选表格记忆
        setSelectRow() {
            if (
                !this.multipleSelectionAll ||
                this.multipleSelectionAll.length <= 0
            ) {
                return
            }
            // 标识当前行的唯一键的名称
            let idKey = this.idKey
            let selectAllIds = []
            let that = this
            this.multipleSelectionAll.forEach(row => {
                selectAllIds.push(row["id"])
            })
            this.$refs.table.clearSelection()
            for (var i = 0; i < this.list.length; i++) {
                if (selectAllIds.indexOf(this.list[i]["id"]) >= 0) {
                    // 设置选中，记住table组件需要使用ref="table"
                    this.$refs.table.toggleRowSelection(this.list[i], true)
                }
            }
        },
        // 记忆选择核心方法
        changePageCoreRecordData() {
            // 标识当前行的唯一键的名称
            let idKey = this.idKey
            // 如果总记忆中还没有选择的数据，那么就直接取当前页选中的数据，不需要后面一系列计算
            if (this.multipleSelectionAll.length <= 0) {
                this.multipleSelectionAll = this.multipleSelection
                // console.log(this.multipleSelectionAll,"this.multipleSelectionAll")
                return
            }

            // 总选择里面的key集合
            let selectAllIds = []
            this.multipleSelectionAll.forEach(row => {
                selectAllIds.push(row["id"])
            })
            console.log(selectAllIds, "selectAllIds")

            let selectIds = []
            // 获取当前页选中的id

            this.multipleSelection.forEach(row => {
                let that = this

                selectIds.push(row["id"])
                // console.log(this.multipleSelection,"this.multipleSelection514")
                // 如果总选择里面不包含当前页选中的数据，那么就加入到总选择集合里
                if (selectAllIds.indexOf(row["id"]) < 0) {
                    that.multipleSelectionAll.push(row)
                }
                // console.log(that.multipleSelectionAll,"this.multipleSelectionAll")
            })

            let noSelectIds = []
            // 得到当前页没有选中的id
            this.list.forEach(row => {
                if (selectIds.indexOf(row["id"]) < 0) {
                    noSelectIds.push(row["id"])
                }
            })
            console.log(noSelectIds, "noSelectIds")

            noSelectIds.forEach(id => {
                let that = this
                if (selectAllIds.indexOf(id) >= 0) {
                    for (let i = 0; i < that.multipleSelectionAll.length; i++) {
                        if (that.multipleSelectionAll[i]["id"] == id) {
                            // 如果总选择中有未被选中的，那么就删除这条
                            that.multipleSelectionAll.splice(i, 1)
                            console.log(
                                that.multipleSelectionAll,
                                "noSelectIds"
                            )
                            break
                        }
                    }
                }
            })
        },
        handleSizeChange(val) {
            this.pageSize = val
            if (this.phoneNumber == "") {
                this.getCustomerList(1, 2)
            } else {
                this.getCustomerList(1, "phone")
            }
            console.log(this.pageSize, 111111)
        },
        /* 切换组员划拨列表 */
        otherChangeTabsClick(tab, event) {
            console.log("5854148")
            console.log(tab)
            if (tab.label == "组员") {
                this.readHua(
                    this.other_huabo_one_cur_page - 1,
                    this.$route.query.id
                )
            } else {
                this.readHua(this.huabo_one_cur_page - 1)
            }
            // console.log(tab, event,"handleClick");
        },
        openReadHua() {
            this.readHua(0)
        },
        // 门店情况 --- 相关
        timeStoreFn(val) {
            this.StoreTime = val
            this.getStoreDetail()
        },
        addStore() {
            this.addStoreDialog = true
            this.activeShow = false
            this.$nextTick(function() {
                this.activeShow = true
            })
            console.log("新增")
            
        // 门店情况
        this.dataStoreFn()
        },
        dataStoreFn(data) {
            //日期搜索预约列表
            let startTime =
                formatDate(new Date(), "yyyy-MM-dd hh:mm:ss").substring(0, 10) +
                " 00:00:00"
            let endTime = formatDate(new Date(), "yyyy-MM-dd hh:mm:ss").substring(0, 10) + " 23:59:59"
            if (!data) {
                let data = []
                data[0] = startTime
                data[1] = endTime
                this.storeStart = data[0]
                this.storeEnd = data[1]
                this.TimeValue = data
            } else {
                this.storeStart = formatDate(data[0], "yyyy-MM-dd hh:mm:ss")
                this.storeEnd = formatDate(data[1], "yyyy-MM-dd hh:mm:ss")
            }
            this.getStoreDetail()
        },
        //门店详情
        getStoreDetail() {
            this.roleName = localStorage.getItem("roleName")
            let hostUrl = (localStorage.getItem("roleName") == "咨询主管")? "/counselorShopRelation/list/shop?timeType=" + this.StoreTime + "&direction=DESC&propertys=createdTime&counselorId=" + this.$route.query.id + "&startTime=" + this.storeStart + "&endTime=" + this.storeEnd :
                           "/counselorShopRelation/list/shop?timeType=" + this.StoreTime + "&direction=DESC&propertys=createdTime&counselorId=" + this.$route.query.id + "&startTime=" + this.storeStart + "&endTime=" + this.storeEnd
                storeAsGet(hostUrl)
                    .then(res => {
                        this.salcTotalObj = {
                                addWechatNumAll : 0,
                                dereceiveNumAll : 0,
                                invalidNumAll : 0,
                                receiveNumAll: 0,
                                tailAfterNumAll: 0,
                                addWechatSurpriseNumAll: 0,
                        }
                        console.log(res.data.content.list, "Store")
                        this.detailStore = res.data.content.list
                        Array.prototype.slice.call(this.detailStore).forEach((value, index) => {
                                value.dereceiveNum = value.receiveNum + value.addWechatNum + value.invalidNum + value.addWechatSurpriseNum + value.tailAfterNum
                                let rateMon = value.dereceiveNum - value.invalidNum
                                                          
                                this.salcTotalObj.addWechatNumAll += value.addWechatNum
                                this.salcTotalObj.addWechatSurpriseNumAll += value.addWechatSurpriseNum
                                this.salcTotalObj.dereceiveNumAll += value.dereceiveNum
                                this.salcTotalObj.invalidNumAll += value.invalidNum
                                this.salcTotalObj.tailAfterNumAll += value.tailAfterNum
                                this.salcTotalObj.receiveNumAll += value.receiveNum

                                if (rateMon == 0 || value.dereceiveNum == 0) {
                                    value.rate = Number(0).toFixed(2) + "%"
                                    value.rateAll = Number(0).toFixed(2) + "%"
                                } else {
                                    value.rate = Number(((value.addWechatNum + value.addWechatSurpriseNum) / (value.dereceiveNum - value.invalidNum)) * 100).toFixed(2) + "%"
                                    value.rateAll = Number(((value.addWechatNum + value.addWechatSurpriseNum) / value.dereceiveNum) * 100).toFixed(2) + "%"
                                }
                            })
                        this.listshopName = []
                        this.detailStore.map(item => {
                            this.listshopName.push({
                                text: item.shopName,
                                value: item.shopName
                            })
                        })
                    })
                    .catch(errors => {
                        this.$message.error(errors.response.data.detail)
                    })
        },
        filterHandler(value, row, column) {
            const property = column["property"]
            return row[property] === value
        },
        /* 重写计算总数 */
        getSummaries(param) {
            const { columns, data } = param
            const sums = []
            columns.forEach((column, index) => {
                if (index === 0) {
                    sums[index] = "合计"
                    return
                }
                if(column.property == 'landPageUrl'){
                    sums[index] = ""
                    return
                }
                
                /* 计算成交率的 key 标识 */
                if (column.property == "rate" || column.property == "rateAll") {
                    let totalObj = this.salcTotalObj
                    console.log(totalObj)
                    if(!totalObj){
                        return false
                    }
                    let temp = totalObj.dereceiveNumAll - totalObj.invalidNumAll
                    let tempAll = totalObj.dereceiveNumAll
                    if(column.property == "rate"){
                        console.log()
                        if(temp == 0){
                            sums[index] = '0.00%'
                            return 
                        }
                        sums[index] = Number(((totalObj.addWechatNumAll + totalObj.addWechatSurpriseNumAll) / temp) * 100 ).toFixed(2) + "%"
                                
                    }else{
                        if(tempAll == 0){
                            sums[index] = '0.00%'
                            return 
                        }
                        sums[index] = Number(((totalObj.addWechatNumAll + totalObj.addWechatSurpriseNumAll) / tempAll) * 100).toFixed(2) + "%"
                    }
                    return
                }
                const values = data.map(item => Number(item[column.property]))
                if (!values.every(value => isNaN(value))) {
                    sums[index] = values.reduce((prev, curr) => {
                        const value = Number(curr)
                        if (!isNaN(value)) {
                            return prev + curr
                        } else {
                            return prev
                        }
                    }, 0)
                    sums[index] += ""
                } else {
                    sums[index] = ""
                }
            })

            return sums
        },
    }
}
</script>

<style scoped>
.store {
    position: relative;
}
.store .store_title {
    height: 40px;
}
.store .store_title div {
    line-height: 40px;
}
.store .mainBtn {
    position: absolute;
    right: 0;
    top: 0;
}
.exd_title span {
    display: inline-block;
    padding: 20px 20px 20px 0;
}
.exd_value {
    margin-bottom: 20px;
}
.exd_ul li {
    padding: 5px 0;
}
.exd_ul_span {
    display: inline-block;
    width: 100px;
    margin-right: 10px;
    text-align: right;
}
.exd-textarea {
    width: 200px;
    vertical-align: top;
    border: 1px solid #dcdfe6;
    height: 32px;
    border-radius: 4px;
    resize: none;
}
.exd-textarea:focus,
.exd-textarea:active {
    border: 1px solid #c0c4cc;
}
.copyBtn {
    margin-left: 10px;
}
.sixCol {
    margin-left: 20px;
    text-align: left !important;
}
</style>
